﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Manager/Base.Master" AutoEventWireup="true"
    CodeBehind="ProjectList.aspx.cs" Inherits="YXQ.Manager.Manager.ProjectList" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script type="text/javascript">
        $(function () {
            $('#dg').datagrid({
                title: '<%=gtitle%>',
            iconCls: 'icon icon-nav',
            height: 420,
            nowrap: true,
            autoRowHeight: false,
            striped: true,
            url: "../Handler/DataHandler.ashx?OpType=GetProJect&PostData=<%=tpid %>",
            sortOrder: 'desc',
            remoteSort: false,
            pagination: true,
            singleSelect: true,
            pageSize: 10,
            pageList: [10, 20, 30],
            //  toolbar: "#toolbar",
            onDblClickRow: ShowRow,
            columns: [[
					    { field: 'Id', title: 'ID', width: 20 },
                        { field: 'ProjectName', title: '项目名称', width: 200 },
                        { field: 'CompName', title: '施工单位', width: 200 },
                        { field: 'HtPrice', title: '合同金额', width: 80 },
                        { field: 'SJrice', title: '审计金额', width: 80 },
                        { field: 'Pay', title: '工程款已付', width: 80 },
                        { field: 'BackPay', title: '工程款已退保证金', width: 120 },
                         { field: 'StartTime', title: '开工时间', width: 70, formatter: Formatterdate },
                        { field: 'EndTime', title: '完工时间', width: 70, formatter: Formatterdate },

                        <%
        if (AdminUser != null)
        {
            if (AdminUser.UserName == "admin")
            {%>
                        { field: 'CreateRealName', title: '创建者', width: 80 },
                        { field: 'CreateTime', title: '创建时间', width: 100 },
                        { field: 'UpdateRealName', title: '修改者', width: 80 },
                           { field: 'UpdateTime', title: '修改时间', width: 100 },
                        <%
            }
        }
        %>
                        { field: 'Tpid', title: 'tpid', hidden: true },
                        {
                            field: 'opt', title: '操作', width: 150, align: 'center',
                            formatter: function (value, rec) {

                                return "<%
        if (AdminUser != null)
        {
            if (!string.IsNullOrEmpty(AdminUser.Depart))
            {%><a href='javascript:' id='edit'  onclick='Edit(" + rec.Id + ")'>编辑</a>&nbsp;&nbsp;<%}
        }%><a href='javascript:'  onclick=block(" + rec.Id + ",'" + rec.ProjectName + "'," + rec.Tpid + ")>详情</a>&nbsp;&nbsp;<% if (AdminUser != null)
                                                                                                                                {
                                                                                                                                    if (AdminUser.UserName == "admin")
                                                                                                                                    {%><a href='javascript:' onclick='Del(" + rec.Id + ")'>删除</a><%}
                                                                                                                                }%>&nbsp;&nbsp;<a href='javascript:' onclick=ShowProject(" + rec.Id + "," + rec.Tpid + ",'" + rec.ProjectName + "') >查看明细</a>";
                            }
                        }
            ]],
                 <% if (AdminUser != null)
               {
                   if (!string.IsNullOrEmpty(AdminUser.Depart))
                   {%>
            toolbar: [{
                id: 'btnadd',
                text: '添加',
                iconCls: 'icon-add',
                handler: function () {
                    YXQ.Manager.OpenDialog('openwin', "Project.aspx?tpid=<%=tpid%>", "添加项目", 600, 200);
                }
            }]
                <%}%>
                  <%}%>


        });

        });
                    function ShowRow(rowindex, rowdata) {
                        YXQ.Manager.OpenDialog('openwin', "ProjectShow.aspx?id=" + rowdata.Id + "&tpid=" + rowdata.Tpid + "", rowdata.ProjectName + "项目详细进度", ($(window).width() - 100), ($(window).height() - 50));
                    }
                    function Edit(val) {
                        YXQ.Manager.OpenDialog('openwin', "Project.aspx?id=" + val + "&tpid=<%=tpid%>", "修改项目", 600, 200);
                    }
                    function ShowProject(val, tpi, ttl) {
                        YXQ.Manager.OpenDialog('openwin', "ProjectShow.aspx?id=" + val + "&tpid=<%=tpid%>", ttl + "项目详细进度", ($(window).width() - 200), ($(window).height() - 20));
    }


    function Del(val) {
        if (confirm("您确定要删除此项目，其相关的所有的数据将会被删除！")) {

            YXQCore.Form.PostData("../Handler/CommonHandler.ashx",
                                { OpType: "Del", PostData: val },
                                function (data) {

                                    if (data.ResultMessage == "Success") {
                                        YXQ.Common.Message("恭喜你操作已经成功");
                                        $("#dg").datagrid("reload");
                                        return;
                                    }

                                });
        }
    }

    function Formatterdate(val, row) {
        if (val == "" || val == null) {
            return "";
        }
        var dt = val.replace("T", " ");
        var rtnDate = new Date(Date.parse(dt.replace(/-/g, "/")));
        return rtnDate.getFullYear() + "-" + (rtnDate.getMonth() + 1) + "-" + rtnDate.getDate();
    }
    function block(cid, pName, tpid) {
        //  var url = "../control/projectdetail.uc?id=" + cid + "&tpid=" + tpid + "&day=" + new Date();
        var url = "projectdetail.aspx?id=" + cid + "&tpid=" + tpid + "&day=" + new Date();

        YXQ.Manager.OpenDialog('openwin', url, pName, ($(window).width() - 200), $(window).height());
    }


 
        function GridSearch() {
            $('#dg').datagrid('load', {
                pname: $('#txtPName').val(),
                compName: $('#compaName').val(),
                startTime: $("#txtStart").val(),
                sendTime: $("#sendTime").val(),
                endTime: $("#txtEnd").val(),
                estartTime: $("#estartTime").val()

            });
        }

    </script>
    <table cellspacing="0" cellpadding="0" width="100%" class="admintable">
        <tr>
            <td>
                <table cellspacing="0" cellpadding="0" class="admintable01">
                    <tr>
                        <td style="width: 20px;">
                            <img src="../images/carfromtable_01.gif" style="margin-top: 2px;" />
                        </td>
                        <td>
                            <b>位置：</b><%=gtitle %>
                        </td>
                        <td style="width: 50px;"></td>
                        <td style="width: 50px;"></td>
                        <td style="width: 15px;"></td>
                    </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td height="10"></td>
        </tr>
    </table>


    <table id="toolbar">
        <tr>
            <% if (AdminUser != null)
               {
                   if (!string.IsNullOrEmpty(AdminUser.Depart))
                   {%>
            <td class="tdtitle" align="left"><a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="addProject()">添加</a>
            </td>
            <%}
               }%>

            <td class="tdtitle" align="left">项目名称：
            </td>
            <td align="left" class="tdtitle">
                <input type="text" id="txtPName" />
            </td>
            <td align="left" class="tdtitle">施工单位：
            </td>
            <td align="left" class="tdtitle">
                <input type="text" id="compaName" />
            </td>
            <td align="left" class="tdtitle">开工时间：
            </td>
            <td align="left" class="tdtitle">
                <input type="text" id="txtStart" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" style="width: 80px;" />-<input type="text" id="sendtime" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" style="width: 80px;" />
            </td>
            <td align="left" class="tdtitle">完工时间：
            </td>
            <td align="left" class="tdtitle">
                <input type="text" id="estartTime" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" style="width: 80px;" />-<input type="text" id="txtEnd" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" style="width: 80px;" />
            </td>
            <td align="left" class="tdtitle">
                <input type="button" id="btnSearch" value="搜索" class="bt_wb1" onclick="GridSearch();" />
            </td>
        </tr>
    </table>
    <table id="dg">
    </table>



</asp:Content>
